# -*- coding: utf-8 -*-
# @Time    : 2024/9/27 20:01
# @Author  : 荒
# @FileName: cos_upload_demo.py
# @Software: PyCharm

from qcloud_cos import CosConfig
from qcloud_cos import CosS3Client

secret_id = 'AKIDobSEzjXGb7jIk6Xfp2JjHsYOrIk8c4Rt' # 替换为用户的 secret_id
secret_key = 'neTDsjccWMHHGJLQczY6lXJ2gJ5viXI0' # 替换为用户的 secret_key
region = 'ap-beijing' # 替换为用户的 region

config = CosConfig(Region=region,SecretId=secret_id,SecretKey=secret_key)
client = CosS3Client(config)

response = client.upload_file(
    Bucket='huang-1329244466',
    LocalFilePath='code.png',  # 本地文件的路径
    Key='p1.png' # 上传后桶的文件名
)
print(response['ETag'])